<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Vue 代码演示</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>
    <div id="app">
        <ul>
            <!--根据数组数据自动渲染页面-->
            <li v-for="item in message">{{item}}</li>
        </ul>
        <button @click="add">添加数据</button>
    </div>

    <script>
        new Vue({
            el: "#app",
            data: {
                message: ["第1条数据", "第2条数据"]
            },
            methods: {
                //向数组添加一条数据即可 
                add: function () {
                    this.message.push("第" + (this.message.length+1) + "条数据");
                }
            }
        })

    </script>
</body>

</html>